%p#notice= notice
%h1 图片列表
%button.btn.btn-default.upload-article-image-btn 上传文章图片

%table.table.table-bordered#article-image-table
  %thead
    %tr
      %th 图片
      %th URL
      %th 操作
  %tbody
    - @images.each do |image|
      %tr
        %td.col-md-2= image_tag image.picture.url, class:'img_responsive', style:'max-width: 300px'
        %td.col-md-9
          = text_field_tag '', image.picture.url, class: 'form-control input-lg'
        %td.col-md-1
          =# link_to '显示', image
          =# link_to '修改', edit_image_path(image)
          = link_to '删除', image, method: :delete, data: { confirm: 'Are you sure?' }
%br
  =# link_to '创建新图片', new_image_path


.hidden
  = form_tag '/images', multipart: true, id: 'upload-article-image-form' do
    = file_field_tag 'image[picture]'

%button.btn.btn-default.upload-article-image-btn 上传文章图片



:javascript

  $('.upload-article-image-btn').click(function(){
    if( !$(this).hasClass('disabled') )
      $('#image_picture').click()
  })

  $('#image_picture').change(function(){
    if( !$('#image_picture').val()=='' ){
      $('.upload-article-image-btn').html('正在上传图片...')
      $('.upload-article-image-btn').addClass('disabled')
      $('#upload-article-image-form').submit()
    }
  
  })